{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true,
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "<Figure size 640x480 with 1 Axes>",
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAjUAAAGwCAYAAABRgJRuAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAs40lEQVR4nO3df3TU1Z3/8dckkAkJyWgwkFAGCNiv30YE+WEQtBUUFaVYupVuu/4Al2UVkaOl/iBtJXK+p41FzuquILLaBXbV+qulFCooRX70u4hBIZVAYRc2NpEkEuE4QyZkAjOf7x/zTUIIEyYxyZ3PZ56Pcz7n3JncGd6Oycxr7ufez3VZlmUJAADA5pJMFwAAANAVCDUAAMARCDUAAMARCDUAAMARCDUAAMARCDUAAMARCDUAAMARepkuoCeFw2FVVVUpIyNDLpfLdDkAACAGlmXp1KlTGjhwoJKSoo/HJFSoqaqqktfrNV0GAADohMrKSg0aNCjqzxMq1GRkZEiKvCiZmZmGqwHQVQIBaeDASLuqSkpPN1sPgK7l9/vl9XqbP8ejSahQ03TKKTMzk1ADOEhycks7M5NQAzjVxaaOJFSoAeBMvXtLjz7a0gaQmAg1AGwvJUV65hnTVQAwjSXdAADAERipAWB74bBUURFpDx4stbPiE4CDEWoA2N7p01JeXqRdV8dEYSBR8X0GAAA4AqEGAAA4AqEGAAA4AqEGAAA4AqEGAAA4AqEGAAA4Aku6Adher17Sgw+2tAEkJv78Adie2y2tWGG6CgCmEWoMCIUtlZSf1PFTDeqfkaqCvCwlJ7W/8ygAAGifbefUPP3003K5XHrkkUdMl9Ihm8uqdf0v39cPX9qth18v1Q9f2q3rf/m+NpdVmy4NsC3LkmprI4dlma4GgCm2DDV79uzRqlWrNHLkSNOldMjmsmrNe2Wvqn0Nre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L774QqFQSAMGDGh1/4ABA1RTU3PBxxQXF8vj8TQfXq+32+oD0I0sl05sHCt/yVBZVjvdLOmsP1XBz7J6rjYAccM2G1pWVVXpa1/7mnbt2qUJEyY03//4449rx44d+vDDD9s8JhgMKnjOeKLf75fX6+X0Uyf7MrQcwdByx/t29vSTFKn33HepZ7Yc1Jrd5W0e19Rn6R1j9O2r2+7mzemnFrxHRPAe0fG+8X76KeZQ8+STT+qpp55SctNv4XkqKio0Z84cbdmyJZan67DGxkalpaXp7bff1owZM5rvnzVrlr788kutX7/+os/BLt2AM7zzSbV+tr5MJwMtn25n/ak6uTVftXtz2aUbcJgu36V77dq1GjdunMrKytr8bNWqVRoxYoR69Yp5MVWHpaSkaOzYsdq6dWvzfeFwWFu3bm01cgPA+W4fmas9P52iX8+9Vv/8g6u1+p5rdezFG3X6v9qO0ABIHDGHmrKyMl111VUaN26ciouLFQ6HVVFRoSlTpujxxx/XsmXLtGnTpu6sVQsXLtRLL72ktWvX6i9/+YvmzZunQCCg++67r1v/XQDxJznJpQnD++k7V39NBUP7SVZnd5AC4BQxD61kZmbq3//93/W9731P999/v9544w2Vl5eroKBAn3zyiYYMGdKddUqS/vZv/1a1tbVavHixampqdPXVV2vz5s1tJg8DAIDE0+GJwp9//rnuvvtubd26Venp6dq4caNuuOGG7qqvSzGnBnCmUEj6058i7W9+s2UCKgBn6PI5NZL061//Wvn5+QqHw82nf2655Rb96Ec/UkN707sBoBslJ0uTJkUOAg2QuGIONd/73vc0d+5cPfXUU9q6dauuuOIKLV26VNu2bdM777yjUaNG6YMPPujOWgEAAKKKeU5NTU2N9u3bp69//eut7p84caJKS0u1aNEi3XDDDWps7wICANANzpyR/vVfI+1//MeW64kASCwxz6kJh8NKSmp/YGfnzp3delXhr4o5NYAzBQJS376Rdl2duE4N4DBdPqfmYoFGUlwHGgAA4GwdmigMAAAQrwg1AADAEQg1AADAEQg1AADAEQg1AADAEbpvW20A6CFut7RxY0sbQGIi1ACwvV69pGnTTFcBwDRO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q86ePas//vGPqqio0Lx587R9+3alp6dr1qxZevrpp9WrF+siAKcj1AAAAEdgTg0AAHAEQg0AAHAEQg0AAHAEQg0AAHAEQg0AAHAEQg0AAHAEQg0AAHAEQg0AAHAEQg0AAHAEQg0AAHAEQg0AAHCE/wfbA7qX5xSoNwAAAABJRU5ErkJggg==\n"
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# coding: utf-8\n",
    "import numpy as np\n",
    "import matplotlib.pylab as plt\n",
    "from gradient_2d import numerical_gradient\n",
    "\n",
    "\n",
    "def gradient_descent(f, init_x, lr=0.01, step_num=100):\n",
    "    x = init_x\n",
    "    x_history = []\n",
    "\n",
    "    for i in range(step_num):\n",
    "        x_history.append( x.copy() )\n",
    "\n",
    "        grad = numerical_gradient(f, x)\n",
    "        x -= lr * grad\n",
    "\n",
    "    return x, np.array(x_history)\n",
    "\n",
    "\n",
    "def function_2(x):\n",
    "    return x[0]**2 + x[1]**2\n",
    "\n",
    "init_x = np.array([-3.0, 4.0])\n",
    "\n",
    "lr = 0.1\n",
    "step_num = 20\n",
    "x, x_history = gradient_descent(function_2, init_x, lr=lr, step_num=step_num)\n",
    "\n",
    "plt.plot( [-5, 5], [0,0], '--b')\n",
    "plt.plot( [0,0], [-5, 5], '--b')\n",
    "plt.plot(x_history[:,0], x_history[:,1], 'o')\n",
    "\n",
    "plt.xlim(-3.5, 3.5)\n",
    "plt.ylim(-4.5, 4.5)\n",
    "plt.xlabel(\"X0\")\n",
    "plt.ylabel(\"X1\")\n",
    "plt.show()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}